package com.zkdcloud.repository;

import com.zkdcloud.domain.CartExtra;
import org.jfaster.mango.annotation.DB;
import org.jfaster.mango.annotation.SQL;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zk123
 * @version 2018/5/23
 */
@DB(table = "cart_extra")
@Repository
public interface CartExtraDao {
    String COLUMNS = "id,cart_id,name,description,price,create_time";

    /**
     * 添加额外费用
     *
     * @param cartExtra cartExtra
     */
    @SQL("insert into #table("+COLUMNS+")values(:id,:cartId,:name,:description,:price,:createTime)")
    void add(CartExtra cartExtra);

    /**
     * 根据购物车获取额外费用详情
     *
     * @param cartId cartId
     * @return extra
     */
    @SQL("select * from #table where cart_id = :1")
    List<CartExtra> getAllByCartId(String cartId);
}
